package org.dromara.comm_lhz.controller;


import cn.dev33.satoken.annotation.SaIgnore;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.AllArgsConstructor;
import org.dromara.comm_lhz.entity.AsVolunteerInfoEntity;
import org.dromara.comm_lhz.service.AsVolunteerInfoHService;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.*;

/**
 * 志愿者信息管理
 */
@RestController
@RequestMapping("/volunteerInfo")
@AllArgsConstructor
public class AsVolunteerInfoHController {

    private AsVolunteerInfoHService asVolunteerInfoHService;

    /**
     * 后台 根据name模糊分页查询志愿者信息
     *
     * @param asVolunteerInfoEntity 志愿者信息实体，用于查询条件
     * @param pageable 分页信息，用于指定分页查询的页码和大小
     * @return 分页查询结果，包含志愿者信息列表和分页信息
     */



    @GetMapping("/selVolunteerInfo")
    public Page<AsVolunteerInfoEntity> selVolunteerInfo(AsVolunteerInfoEntity asVolunteerInfoEntity, Pageable pageable) {
        return asVolunteerInfoHService.selVolunteerInfo(asVolunteerInfoEntity, pageable);
    }

    /**
     * 添加志愿者信息
     * @param asVolunteerInfoEntity 志愿者信息实体，通过请求体传输
     */
    @PostMapping("/addVolunteerInfo")
    public void addVolunteerInfo(@RequestBody AsVolunteerInfoEntity asVolunteerInfoEntity) {
        asVolunteerInfoHService.save(asVolunteerInfoEntity);
    }

    /**
     * 更新志愿者信息
     * @param asVolunteerInfoEntity 志愿者信息实体，通过请求体传输
     */
    @PutMapping("/updateVolunteerInfo")
    public void updateVolunteerInfo(@RequestBody AsVolunteerInfoEntity asVolunteerInfoEntity) {
        asVolunteerInfoHService.updateById(asVolunteerInfoEntity);
    }

    /**
     * 删除志愿者信息
     * @param id 志愿者信息的唯一标识，通过请求参数传输
     */
    @DeleteMapping("/deleteVolunteerInfo")
    public void deleteVolunteerInfo(@RequestParam("id") Long id) {
        asVolunteerInfoHService.removeById(id);
    }

    /**
     * 查询申请列表
     * @param asVolunteerInfoEntity 志愿者信息实体，用于查询条件
     * @param pageable 分页信息，用于指定分页查询的页码和大小
     * @return 分页查询结果，包含符合条件的志愿者信息列表和分页信息
     */
    @GetMapping("/getVolunteerInfoByState")
    public Page<AsVolunteerInfoEntity> getVolunteerInfoByState(AsVolunteerInfoEntity asVolunteerInfoEntity, Pageable pageable) {
        return asVolunteerInfoHService.getVolunteerInfoByState(asVolunteerInfoEntity, pageable);
    }

}
